<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.tooltip');
JPluginHelper::importPlugin('content');
$dispatcher	= JDispatcher::getInstance();
if (!class_exists('plgContentLightShop')) {
	JError::raiseWarning(50, str_rot13('WYVO_FUBC_REEBE_YBNQ_CYHTVA'));
}
?>
<link rel="stylesheet" href="<?php echo JURI::root().'components/com_shop/assets/'; ?>style.css" type="text/css" />

<!-- Display New Product -->

<?php if($this->state->get('product.isnew') == 1) : ?>
<?php
	$count = count($this->news);
	$_row = ceil($count/$this->state->get('page.columns'));
	$_column = $this->state->get('page.columns');
	$per = floor(100/$_column);
?>
        <div class="item_page_title">
        <h2><?php echo $this->state->get('product.newtitle'); ?></h2>
        </div>
    <table border="0" cellpadding="0" cellspacing="0" width="100%" class="shop-home-table">
    <tbody>
        <?php for($i = 0 ; $i < $_row ; $i++):?>
        <tr>
            <?php for($j = 0 ; $j < $_column; $j++):?>
                <?php if(isset($this->news[$i*$_column+$j])):
                $item = $this->news[$i*$_column+$j];
    $link = JRoute::_('index.php?option=com_shop&view=detail&id='.$item->id.':'.$item->alias);
                ?>
                <td width="<?php echo $per; ?>%" valign="top">
                <div class="shop-home-item-p">
                    <a href="<?php echo $link; ?>" title="<?php echo $item->title; ?>"><img src="<?php echo $this->path_img.'thumb/'.$item->image; ?>" alt="<?php echo $item->alias; ?>" title="<?php echo $item->title; ?>" width="<?php echo $this->state->get('product.widthimg'); ?>" height="<?php echo $this->state->get('product.heightimg'); ?>" class="shop-home-pape-img" /></a>
                    <div class="item_p_title"><h2><a href="<?php echo $link; ?>" class="hasTip" title="<?php echo $this->state->get('page.page_title').'::'.$item->title; ?>"><?php echo $item->title; ?></a></h2>
                    </div>
    <?php if($this->state->get('product.price')):?>
    <div class="shop-home-price">
                    <strong><?php echo JText::_('PRICE'); ?>: </strong><?php 
    $price = $item->price; $dispatcher->trigger('onFormatPrice',array($price,$item->currency,&$price)); echo $price;
    ?> </div>
    <?php endif;?>
    <?php if($this->state->get('product.oldprice')):?>
    <div class="shop-home-old-price">
                    <strong><?php echo JText::_('OLD PRICE'); ?>: </strong><?php 
    $oldprice = $item->old_price; $dispatcher->trigger('onFormatPrice',array($oldprice,$item->currency,&$oldprice)); echo $oldprice;
    ?> </div>
    <?php endif;?>
    <?php if($this->state->get('product.button')):?>
    <div class="shop-home-button">
    <div class="shop-home-button-lft">
    <a href="<?php echo JRoute::_('index.php?option=com_shop&view=order&id='.$item->id.':'.$item->alias); ?>" title="<?php echo $item->title; ?>" class="shop-home-button-order"><?php echo JText::_('ORDER'); ?></a>
    </div>
    <div class="shop-home-button-rgt">
    <a href="<?php echo $link; ?>" title="<?php echo $item->title; ?>" class="shop-home-button-detail"><?php echo JText::_('DETAIL'); ?></a>
    </div>
    </div>
    <?php endif;?>
                </div>
                </td>
                <?php else:?>
                <td width="<?php echo $per;?>%"></td>
                <?php endif;?>
            <?php endfor;?>
        </tr>
        <?php endfor;?>
    </tbody>
    </table>
<?php endif; ?>

<!-- Display Sale Product -->

<?php if($this->state->get('product.issale') == 1) : ?>
<?php
	$count = count($this->sales);
	$_row = ceil($count/$this->state->get('page.columns'));
	$_column = $this->state->get('page.columns');
	$per = floor(100/$_column);
?>
        <div class="item_page_title">
        <h2><?php echo $this->state->get('product.saletitle'); ?></h2>
        </div>
    <table border="0" cellpadding="0" cellspacing="0" width="100%" class="shop-home-table">
    <tbody>
        <?php for($i = 0 ; $i < $_row ; $i++):?>
        <tr>
            <?php for($j = 0 ; $j < $_column; $j++):?>
                <?php if(isset($this->sales[$i*$_column+$j])):
                $item = $this->sales[$i*$_column+$j];
    $link = JRoute::_('index.php?option=com_shop&view=detail&id='.$item->id.':'.$item->alias);
                ?>
                <td width="<?php echo $per; ?>%" valign="top">
                <div class="shop-home-item-p">
                    <a href="<?php echo $link; ?>" title="<?php echo $item->title; ?>"><img src="<?php echo $this->path_img.'thumb/'.$item->image; ?>" alt="<?php echo $item->alias; ?>" title="<?php echo $item->title; ?>" width="<?php echo $this->state->get('product.widthimg'); ?>" height="<?php echo $this->state->get('product.heightimg'); ?>" class="shop-home-pape-img" /></a>
                    <div class="item_p_title"><h2><a href="<?php echo $link; ?>" class="hasTip" title="<?php echo $this->state->get('page.page_title').'::'.$item->title; ?>"><?php echo $item->title; ?></a></h2>
                    </div>
    <?php if($this->state->get('product.price')):?>
    <div class="shop-home-price">
                    <strong><?php echo JText::_('PRICE'); ?>: </strong><?php 
    $price = $item->price; $dispatcher->trigger('onFormatPrice',array($price,$item->currency,&$price)); echo $price;
    ?> </div>
    <?php endif;?>
    <?php if($this->state->get('product.oldprice')):?>
    <div class="shop-home-old-price">
                    <strong><?php echo JText::_('OLD PRICE'); ?>: </strong><?php 
    $oldprice = $item->old_price; $dispatcher->trigger('onFormatPrice',array($oldprice,$item->currency,&$oldprice)); echo $oldprice;
    ?> </div>
    <?php endif;?>
    <?php if($this->state->get('product.button')):?>
    <div class="shop-home-button">
    <div class="shop-home-button-lft">
    <a href="<?php echo JRoute::_('index.php?option=com_shop&view=order&id='.$item->id.':'.$item->alias); ?>" title="<?php echo $item->title; ?>" class="shop-home-button-order"><?php echo JText::_('ORDER'); ?></a>
    </div>
    <div class="shop-home-button-rgt">
    <a href="<?php echo $link; ?>" title="<?php echo $item->title; ?>" class="shop-home-button-detail"><?php echo JText::_('DETAIL'); ?></a>
    </div>
    </div>
    <?php endif;?>
                </div>
                </td>
                <?php else:?>
                <td width="<?php echo $per;?>%"></td>
                <?php endif;?>
            <?php endfor;?>
        </tr>
        <?php endfor;?>
    </tbody>
    </table>
<?php endif; ?>

<!-- Display Lot Product -->

<?php if($this->state->get('product.islot') == 1) : ?>
<?php
	$count = count($this->lots);
	$_row = ceil($count/$this->state->get('page.columns'));
	$_column = $this->state->get('page.columns');
	$per = floor(100/$_column);
?>
        <div class="item_page_title">
        <h2><?php echo $this->state->get('product.lottitle'); ?></h2>
        </div>
    <table border="0" cellpadding="0" cellspacing="0" width="100%" class="shop-home-table">
    <tbody>
        <?php for($i = 0 ; $i < $_row ; $i++):?>
        <tr>
            <?php for($j = 0 ; $j < $_column; $j++):?>
                <?php if(isset($this->lots[$i*$_column+$j])):
                $item = $this->lots[$i*$_column+$j];
    $link = JRoute::_('index.php?option=com_shop&view=detail&id='.$item->id.':'.$item->alias);
                ?>
                <td width="<?php echo $per; ?>%" valign="top">
                <div class="shop-home-item-p">
                    <a href="<?php echo $link; ?>" title="<?php echo $item->title; ?>"><img src="<?php echo $this->path_img.'thumb/'.$item->image; ?>" alt="<?php echo $item->alias; ?>" title="<?php echo $item->title; ?>" width="<?php echo $this->state->get('product.widthimg'); ?>" height="<?php echo $this->state->get('product.heightimg'); ?>" class="shop-home-pape-img" /></a>
                    <div class="item_p_title"><h2><a href="<?php echo $link; ?>" class="hasTip" title="<?php echo $this->state->get('page.page_title').'::'.$item->title; ?>"><?php echo $item->title; ?></a></h2>
                    </div>
    <?php if($this->state->get('product.price')):?>
    <div class="shop-home-price">
                    <strong><?php echo JText::_('PRICE'); ?>: </strong><?php 
    $price = $item->price; $dispatcher->trigger('onFormatPrice',array($price,$item->currency,&$price)); echo $price;
    ?> </div>
    <?php endif;?>
    <?php if($this->state->get('product.oldprice')):?>
    <div class="shop-home-old-price">
                    <strong><?php echo JText::_('OLD PRICE'); ?>: </strong><?php 
    $oldprice = $item->old_price; $dispatcher->trigger('onFormatPrice',array($oldprice,$item->currency,&$oldprice)); echo $oldprice;
    ?> </div>
    <?php endif;?>
    <?php if($this->state->get('product.button')):?>
    <div class="shop-home-button">
    <div class="shop-home-button-lft">
    <a href="<?php echo JRoute::_('index.php?option=com_shop&view=order&id='.$item->id.':'.$item->alias); ?>" title="<?php echo $item->title; ?>" class="shop-home-button-order"><?php echo JText::_('ORDER'); ?></a>
    </div>
    <div class="shop-home-button-rgt">
    <a href="<?php echo $link; ?>" title="<?php echo $item->title; ?>" class="shop-home-button-detail"><?php echo JText::_('DETAIL'); ?></a>
    </div>
    </div>
    <?php endif;?>
                </div>
                </td>
                <?php else:?>
                <td width="<?php echo $per;?>%"></td>
                <?php endif;?>
            <?php endfor;?>
        </tr>
        <?php endfor;?>
    </tbody>
    </table>
<?php endif; ?>
